<template>
<view class="dialog-login" v-if="show" @tap="onCloseLoginDialog">
  <view class="dialog-body" @tap.stop="onDialogBody">
    <view class="title">请选择登录方式</view>
    <view class="content">
		
      <!-- <button type="primary" open-type="getUserInfo" @getuserinfo="onWechatLogin">微信登录</button> -->
	  
      <form>
		  <input type="number" :value="user.phone" placeholder="手机号码">
		  <view>
			<input :value="user.testnum" placeholder="验证码">
			<view>发送验证码</view>  
		  </view>
		  <view>
			  <button>登入</button>
			  <button>重置</button>
		  </view>
	  </form>
	
    </view>
  </view>
</view>
</template>

<script>
// pages/component/login/login.js
var util = require("../../utils/util.js"); // var api = require('../../config/api.js');
// var api = require('../../config/api.js');
var app = getApp();

export default {
  data() {
    return {
      // show: false
    };
  },

  components: {},
  props: {
    show: {
      type: Boolean
    }
  },
  methods: {
    onCloseLoginDialog() {
      this.setData({
        show: false
      });
    },

    onWechatLogin: function (e) {
      // console.log("==onWechatLogin=="+JSON.stringify(e))
      if (e.detail.errMsg !== 'getUserInfo:ok') {
        if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
          return false;
        }

        uni.showToast({
          title: '微信登录失败'
        });
        return false;
      }

      uni.showLoading({
        title: '登陆中...'
      });
      util.loginByWeixin().then(res => {
        uni.hideLoading(); // 设置用户信息

        if (res.errno == 0) {
          this.setData({
            show: false
          });
          this.$emit("success", {
            detail: app.globalData.userInfo
          });
        }
      });
    }
  }
};
</script>
<style>

.dialog-login{
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5); 
  display: flex;
  justify-content: center;
  align-items: center;
}


.dialog-login .dialog-body{
  width: 540rpx;
  height: auto;
  overflow: hidden;
  background: #fff;
  border-radius: 5px;
  padding: 40rpx;
}

.dialog-login .dialog-body .title{
  width: 100%;
  text-align: center;
  line-height: 60rpx;
}

.dialog-login .dialog-body .content{
  width: 100%;
}

.dialog-login .dialog-body button{
  margin-top: 30rpx;
}
</style>